#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   dhcp_service.sh
# Version:    1.0
# Date:       2013/09/22
# Author:     huijing.hei
# Email:      huijing.hei@cs2c.com.cn
# Summary:    02系统基本功能-04网络服务-07DHCP-04查看租约信息
# Notes:       ***
# Copyright:    China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/10/15
#             - setup dhcpd.conf, start dhcpd service, and assign dynamic IP to clients.
#             - check leases info
# ----------------------------------------------------------------------

##! @TODO:  start and stop dhcpd service.
##! @AUTHOR: huijing.hei
##! @VERSION: 1.0 
##! @OUT: 0 => success; 1 => failure

function do_test()
{
    echo "Test: check dhcp leases."    

    LEASES="/var/lib/dhcpd/dhcpd.leases"

    sleep 10

    # check leases info
    lines=0
    HW=""
    if [ -s ${LEASES} ]
    then
        cat ${LEASES}
    else
        echo "${LEASES} not exist, or null file"
        exit 1
    fi

    EchoResult "testcase: check dhcp lease info."

}


# include lib files

if [ -z "$SFROOT" ]
then
    CMDLIB=./
    SFROOT=./
else
    CMDLIB=${SFROOT}/testcases/Network_Service
fi

. ${SFROOT}/lib/Echo.sh

do_test || { echo "testcase failed."; exit 1; }
